package initialize

import (
	"fmt"
	"github.com/go-redis/redis"
	"week1zk-project/user-rpc/global"
)

var Rdb *redis.Client

//初始化redis

func InitRedis() {
	redisConfig := global.AppData.Service.Redis
	client := redis.NewClient(&redis.Options{
		Addr:     redisConfig.Addr,
		Password: redisConfig.Password, // no password set
		DB:       redisConfig.Db,       // use default DB
	})

	pong, err := client.Ping().Result()
	fmt.Println(pong, err)
	// Output: PONG <nil>
}
